<div id="bloc_description" style="margin-top:10px;">
	<?php
	$erreur=0;
	if(isset($_GET['id']) || isset($_POST['id'])) {
		if (isset($_GET['id'])) {
			$id=$_GET['id'];
			$newsletter = new dc_newsletter_basic();
			$query = "select * from $newsletter->table where id='$id'";
			$resul = mysql_query($query, $newsletter->link);
        	if (!$resul) { die('Erreur: ' . mysql_error() . '<br/>Req: ' . $query);}
        	if (mysql_num_rows($resul)==0) $erreur=1;
			$row = mysql_fetch_object($resul);
			$email = $row->email;
			$name = $row->nom;
			$prenom = $row->prenom;
			$date = $row->date;
			$langue = $row->langue;
		} else {
			$id=$_POST['id'];
			$email=addslashes($_POST['email']);
			$name=addslashes($_POST['name']);
			$prenom=addslashes($_POST['prenom']);
			$date=addslashes($_POST['date']);
			$langue==addslashes($_POST['langue']);
		}
	}
	
	if ($id!="" && $erreur==0) {
	?>
	<form action="?nom=<?php echo $nom; ?>&amp;page=liste_modifier" name="modifier" id="formulaire" method="POST">
		<input type="hidden" name="edit" value="1" />	
		<div class="entete_liste_config">
			<div class="titre">DETAILS DE L'ABONN&Eacute;</div>
			<div class="fonction_valider">
				<a href="#" onclick="document.getElementById('formulaire').submit();">VALIDER</a>
			</div>
		</div>
		<table width="100%" cellpadding="5" cellspacing="0">
			<tr class="claire">
     			<td class="designation">Id</td>
        		<td><?php echo $id; ?><input type="hidden" name="id" value="<?php echo $id; ?>" /></td>
   			</tr>
			<tr class="fonce">
       			<td class="designation">Adresse email</td>
       			<td>
       				<input type="text" class="form_long" name="email" value="<?php echo $email; ?>" />
       			</td>
   			</tr>
			<tr class="claire">
  				<td class="designation">Nom</td>
       			<td>
       				<input type="text" class="form_long" name="name" value="<?php echo $name; ?>" />
       			</td>
   			</tr>
			<tr class="fonce">
        		<td class="designation">Pr&eacute;nom</td>
        		<td>
        			<input type="text" class="form_long" name="prenom" value="<?php echo $prenom; ?>" />
        		</td>
   			</tr>
   			<tr class="claire">
  				<td class="designation">Date d'abonnement</td>
       			<td><?php echo $date; ?><input type="hidden" name="date" value="<?php echo $date; ?>" /></td>
   			</tr>
        	<tr class="fonce">
        		<td class="designation">Langue</td>
        		<td>
        			<select class="form_long" name="langue">
        			<?php
        			$dc_lang = new Lang();
        			$query_lang = 'select * from ' . $dc_lang->table;
					$resul_lang = mysql_query($query_lang);
					while($rowlang = mysql_fetch_object($resul_lang)) {
                     	echo '<option value="'. $rowlang->id;
                     	if($rowlang->id==$langue) echo 'selected="selected"';
                     	echo '">'.$rowlang->description.'</option>';
                   	}
        			?>
        			</select>
        		</td>
   			</tr>
			<tr class="clairebottom">
				<td class="designation">&nbsp;</td>
				<td>
					<?
 		           	if ($_POST['edit']==1) {
						$newsletter = new dc_newsletter_basic();
						// Vérification email non vide
						if ($email == "" || !isset($email)) {
							echo '<strong style="color:red;">Erreur: Le champ email est vide.</strong>';
						} else {
							// Vérification email valide
 				           	if ($newsletter->checkemail($email)) {
								// Vérification email déjà présente
								$query = "select * from $newsletter->table where email='$email' AND id!='$id'";
								$resul = mysql_query($query);
								if (mysql_num_rows($resul)>0) {
                       	        	echo '<strong style="color:red;">Erreur: L\'adresse email existe d&eacute;j&agrave;.</strong>';
                   	        	} else {
                   	        		$modif = mysql_query("UPDATE $newsletter->table SET email='$email', nom='$name', prenom='$prenom', langue='$langue' WHERE id='$id'");
                               		echo'<strong style="color:green;">Modification de '.$email.' effectu&eacute;e</strong>';
                   	        	}
							} else {
								echo '<strong style="color:red;">Erreur: L\'adresse email '. $email .' n\'est pas valide</strong>';
							}
						}
					}
					?>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<?php } ?>
</div>